﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace VkClientIM.Logic
{
	public class Message
		: INotifyPropertyChanged
	{
		private long _messageID;
		private string _messageTitle;
		private string _messageBody;
		private Profile _user;
		private long _time;
		private bool _out;

		public Message()
		{

		}

		public Message(long messageID)
		{
			_messageID = messageID;
		}

		public long MessageID
		{
			get { return _messageID; }
			set
			{
				if (_messageID != value)
				{
					_messageID = value;
					if (PropertyChanged != null)
					{
						PropertyChanged(this, new PropertyChangedEventArgs("MessageID"));
					}
				}
			}
		}

		public string MessageTitle
		{
			get { return _messageTitle; }
			set
			{
				if (_messageTitle != value)
				{
					_messageTitle = value;
					if (PropertyChanged != null)
					{
						PropertyChanged(this, new PropertyChangedEventArgs("MessageTitle"));
					}
				}
			}
		}

		public string MessageBody
		{
			get { return _messageBody; }
			set
			{
				if (_messageBody != value)
				{
					_messageBody = value;
					if (PropertyChanged != null)
					{
						PropertyChanged(this, new PropertyChangedEventArgs("MessageBody"));
					}
				}
			}
		}

		public Profile User
		{
			get { return _user; }
			set
			{
				if (_user != value)
				{
					_user = value;
					if (PropertyChanged != null)
					{
						PropertyChanged(this, new PropertyChangedEventArgs("User"));
					}
				}
			}
		}

		public long UnixTime
		{
			get { return _time; }
			set
			{
				if (_time != value)
				{
					_time = value;
					if (PropertyChanged != null)
					{
						PropertyChanged(this, new PropertyChangedEventArgs("UnixTime"));
						PropertyChanged(this, new PropertyChangedEventArgs("WindowsTime"));
					}
				}
			}
		}

		public DateTime WindowsTime
		{
			get { return Vkontakte.Api.Utils.FromUnixTimeStampToDateTime( _time ); }
		}

		public bool Out
		{
			get { return _out; }
			set
			{
				if (_out!=value)
				{
					_out = value;
					if (PropertyChanged!=null)
					{
						PropertyChanged( this, new PropertyChangedEventArgs( "Out" ) );
					}
				}
			}
		}

		public event PropertyChangedEventHandler PropertyChanged;
	}
}
